package pers.baiban.sqltoword.enums;

import lombok.Getter;
import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBorder;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STVerticalJc;
import pers.baiban.sqltoword.config.TableParam;
import pers.baiban.sqltoword.constant.SRMConstant;
import pers.baiban.sqltoword.constant.TableConstant;

/**
 * 表格样式枚举
 *
 * @author 强子初
 * @since 2023/11/28
 */
@Getter
public enum TableStyle {
    THREE_LINE_TABLE("三线表") {
        @Override
        public TableParam build() {
            return super.build()
                    .setTableBorder(STBorder.NONE)
                    .setTableBorderTop(STBorder.SINGLE)
                    .setTableBorderBottom(STBorder.SINGLE)
                    .setTableCellAlignment(ParagraphAlignment.CENTER)
                    .setTableCellSTVerticalJc(STVerticalJc.CENTER)
                    .setHeaderBorderBottom(STBorder.SINGLE)
                    .setHeaderBorderBottomWidth(BorderWidth.POUNDS_50)
                    .setTableBorderBottomWidth(BorderWidth.POUNDS_150)
                    .setTableBorderTopWidth(BorderWidth.POUNDS_150)
                    .setTableCellFont("宋体", FontSize.NO_5);
        }
    },
    TLANG("螳螂网配置") {
        @Override
        public TableParam build() {
            return super.build()
                    .setHeaderColor(Color.C6D9F1);
        }
    },
    SRM("SRM配置") {
        @Override
        public TableParam build() {
            return super.build()
                    .setTableHeader(SRMConstant.DEFAULT_TABLE_HEADER)
                    .setTableHeaderWidth(SRMConstant.DEFAULT_TABLE_HEADER_WIDTH)
                    .setTableColumn(SRMConstant.DEFAULT_TABLE_COLUMN)
                    .setTableBorder(STBorder.SINGLE)
                    .setTableBorderWidth(BorderWidth.POUNDS_150);
        }
    },
    DEFAULT("默认");

    private final String desc;

    private final TableParam tableParam;

    TableStyle(String desc) {
        this.desc = desc;
        this.tableParam = build();
    }

    public TableParam build() {
        return new TableParam()
                .setTitleTextFormat("{1}【{2}】")
                .setTitleFontFamily("等线")
                .setTitleFontSize(FontSize.NO_3)
                .setTableHeader(TableConstant.DEFAULT_TABLE_HEADER)
                .setTableHeaderWidth(TableConstant.DEFAULT_TABLE_HEADER_WIDTH)
                .setTableColumn(TableConstant.DEFAULT_TABLE_COLUMN)
                .setTableCellAlignment(ParagraphAlignment.CENTER)
                .setTableCellSTVerticalJc(STVerticalJc.CENTER);
    }
}